package com.ruoyi.car.service.impl;

import java.util.List;

import com.ruoyi.car.service.ICarInfoService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.car.mapper.CarGasolineMapper;
import com.ruoyi.car.domain.CarGasoline;
import com.ruoyi.car.service.ICarGasolineService;

/**
 * 加油Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-12-03
 */
@Service
public class CarGasolineServiceImpl implements ICarGasolineService 
{
    @Autowired
    private CarGasolineMapper carGasolineMapper;

    @Autowired
    private ICarInfoService carInfoService;

    /**
     * 查询加油
     * 
     * @param gasolineId 加油主键
     * @return 加油
     */
    @Override
    public CarGasoline selectCarGasolineByGasolineId(Long gasolineId)
    {
        return carGasolineMapper.selectCarGasolineByGasolineId(gasolineId);
    }

    /**
     * 查询加油列表
     * 
     * @param carGasoline 加油
     * @return 加油
     */
    @Override
    public List<CarGasoline> selectCarGasolineList(CarGasoline carGasoline)
    {
        return carGasolineMapper.selectCarGasolineList(carGasoline);
    }

    /**
     * 新增加油
     * 
     * @param carGasoline 加油
     * @return 结果
     */
    @Override
    public int insertCarGasoline(CarGasoline carGasoline)
    {
        //判断车牌
        carInfoService.compare(carGasoline.getCarNumber());
        carGasoline.setCreateTime(DateUtils.getNowDate());
        return carGasolineMapper.insertCarGasoline(carGasoline);
    }

    /**
     * 修改加油
     * 
     * @param carGasoline 加油
     * @return 结果
     */
    @Override
    public int updateCarGasoline(CarGasoline carGasoline)
    {
        carGasoline.setUpdateTime(DateUtils.getNowDate());
        return carGasolineMapper.updateCarGasoline(carGasoline);
    }

    /**
     * 批量删除加油
     * 
     * @param gasolineIds 需要删除的加油主键
     * @return 结果
     */
    @Override
    public int deleteCarGasolineByGasolineIds(Long[] gasolineIds)
    {
        return carGasolineMapper.deleteCarGasolineByGasolineIds(gasolineIds);
    }

    /**
     * 删除加油信息
     * 
     * @param gasolineId 加油主键
     * @return 结果
     */
    @Override
    public int deleteCarGasolineByGasolineId(Long gasolineId)
    {
        return carGasolineMapper.deleteCarGasolineByGasolineId(gasolineId);
    }
}
